//
//  Account.m
//  WeChat
//
//  Created by wangcarl on 16/8/29.
//  Copyright © 2016年 wangcarl. All rights reserved.
//

#import "Account.h"
#define kUserKey @"user"
#define kPwdKey @"pwd"
#define kLoginKey @"login"

static NSString *domain=@"carl.local";
static NSString *host=@"127.0.0.1";
static int port=5222;

@implementation Account
+(instancetype)shareAccount;
{
    return [[self alloc] init];
}
+(instancetype)allocWithZone:(struct _NSZone *)zone
{
    static Account *account;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        if (account==nil) {
            account=[super allocWithZone:zone];
            
         NSUserDefaults *defaults=[NSUserDefaults standardUserDefaults];
            account.user=[defaults objectForKey:kUserKey];
            account.pwd =[defaults objectForKey:kPwdKey];
            account.login=[defaults boolForKey:kLoginKey];
        }
    });
    return account;
}

-(void)saveToSandBox
{
    NSUserDefaults *defaults=[NSUserDefaults standardUserDefaults];
    [defaults setObject:self.user forKey:kUserKey];
    [defaults setObject:self.pwd  forKey:kPwdKey];
    [defaults setBool:self.isLogin forKey:kLoginKey];
    [defaults synchronize];
    
    
    
}

-(NSString *)domain
{
    return domain;
}
-(NSString *)host
{
    return host;
}
-(int)port{
    return port;
}
@end
